<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>JS实现倒计时(天数,时,分,秒)</title>
    <script language="javascript" type="text/javascript">
        function leftTimer(second) {
            var seconds = parseInt(second);//计算剩余的秒数
            seconds--;
            if (seconds < 0) {
                alert("结束倒计时")
            } else {
//                console.log(seconds);
                var out = checkTime(seconds);
                document.getElementById("timer").innerHTML = out + "秒";
                setTimeout(function () {
                    leftTimer(seconds)
                }, 1000)
            }
        }
        function checkTime(i) { //将0-9的数字前面加上0，例1变为01
            if (i < 10) {
                i = "0" + i;
            }
            return i;
        }
        setInterval("document.getElementById('linkweb').innerHTML='当前时间是:'+ " +
                "new Date  ().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay  ());", 1000);
    </script>

</head>
<body onload="leftTimer(60)">

<div id="linkweb" style=" display:inline;"></div>
<h2>剩余时间:</h2>
<div id="timer"></div>
</body>
</html>
